import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

export default new Router({
  routes: [
    {
      path: '/home',
      name: 'home',
      component: () => import('./views/home/index.vue')
    },
    {
      path: '/search',
      name: 'search',
      component: () => import('./views/home/search.vue'),
      meta: { keepAlive: true }
    },
    {
      path: '/follow',
      name: 'follow',
      component: () => import('./views/home/follow.vue')
    },
    {
      path: '/user',
      name: 'user',
      component: () => import('./views/home/user.vue')
    },
    {
      path: '/overview',
      name: 'overview',
      component: () => import('./views/home/overview.vue')
    },
    {
      path: '/battle',
      name: 'battle',
      component: () => import('./views/home/battle.vue')
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('./views/login/index.vue')
    },
    {
      path: '/resource',
      name: 'resource',
      component: () => import('./views/resource/index.vue')
    },
    {
      path: '/customer',
      name: 'customer',
      component: () => import('./views/resource/customer.vue'),
      meta: { keepAlive: true }
    },
    {
      path: '/statisticsOrder',
      name: 'statisticsOrder',
      component: () => import('./views/statistics/order.vue')
    },
    {
      path: '/statisticsBusiness',
      name: 'statisticsBusiness',
      component: () => import('./views/statistics/business.vue')
    },
    {
      path: '/business',
      name: 'business',
      component: () => import('./views/resource/business.vue'),
      meta: { keepAlive: true },
      beforeEnter: (to, from, next) => {
        if (from.name === 'home') {
          // eslint-disable-next-line
          to.query.isOnlyShowPerf = true;
        }
        next();
      }
    },
    {
      path: '/performance',
      name: 'performance',
      component: () => import('./views/resource/performance.vue')
    },
    {
      path: '/order',
      name: 'order',
      component: () => import('./views/order/index.vue')
    },
    {
      path: '/alarm',
      name: 'alarm',
      component: () => import('./views/alarm/index.vue')
    },
    {
      path: '/dial',
      name: 'dial',
      component: () => import('./views/dial/index.vue'),
      meta: { keepAlive: true }
    },
    {
      path: '/dialDetails',
      name: 'dialDetails',
      component: () => import('./views/dial/details.vue')
    },
    {
      path: '/subject',
      name: 'subject',
      component: () => import('./views/subject/index.vue')
    },
    {
      path: '/silence',
      name: 'silence',
      component: () => import('./views/subject/silence.vue'),
      meta: { keepAlive: true }
    },
    {
      path: '/excessive',
      name: 'excessive',
      component: () => import('./views/subject/excessive.vue'),
      meta: { keepAlive: true }
    },
    {
      path: '/excessiveDetial',
      name: 'excessiveDetial',
      component: () => import('./views/subject/detials.vue')
    },
    {
      path: '/service',
      name: 'service',
      component: () => import('./views/service/index.vue')
    },
    {
      path: '/topology',
      name: 'topology',
      component: () => import('./views/resource/topology.vue')
    },
    {
      path: '/visit',
      name: 'visit',
      component: () => import('./views/service/visit.vue')
    },
    {
      path: '/building',
      name: 'building',
      component: () => import('./views/other/building.vue')
    },
    {
      path: '/modifyPsw',
      name: 'modifyPsw',
      component: () => import('./views/mine/modifyPsw.vue')
    },
    {
      path: '/scanCode',
      name: 'scanCode',
      component: () => import('./views/mine/scanCode.vue')
    },
    {
      path: '/',
      redirect: '/home'
    }
  ]
});
